﻿using AutoMapper;
using Common.Communal;
using ERP.Domain.CustomerSupplier;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Sell.Api.Write.Application.Command.SupplierCommand;

namespace Sell.Api.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SupplierController : ControllerBase
    {
        private IMediator mediator { get; }
        public SupplierController(IMediator _mediator)
        {
            mediator= _mediator;
        }
        /// <summary>
        /// 供应商管理添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> SupplierAdd(SupplierAddCommand request)
        {
           return await mediator.Send(request);
        }
        /// <summary>
        /// 供应商管理删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<ApiResult<int>> SupplierDel([FromQuery]SupplierDelCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 供应商管理修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> SupplierUpdate(SupplierUpdateCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
